package com.cuit.xsc.weishare.adapter;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.cuit.xsc.weishare.R;
import com.cuit.xsc.weishare.model.UserInfo;
import com.cuit.xsc.weishare.util.LogUtil;

public class UserSelecteAdapter extends ArrayListAdapter<UserInfo>
{
	private LayoutInflater inflater;


	
	public UserSelecteAdapter(Activity context)
	{
		super(context);
		inflater = LayoutInflater.from(context);
	}

	public final class ViewHolder
	{
		public TextView rName;
		public TextView rValue;
	
		
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		
		View row = convertView;
		ViewHolder holder;
		
		
		if (row == null)
		{
			holder = new ViewHolder();
			row = inflater.inflate(R.layout.user_selecte_item, null);
			holder.rName = (TextView) row.findViewById(R.id.user_name);
			holder.rValue = (TextView) row.findViewById(R.id.textView2);
		
			row.setTag(holder);
		}
		else 
		{
			holder = (ViewHolder)row.getTag();
		}
//		LayoutInflater _LayoutInflater = LayoutInflater.from(mContext);
//		convertView = _LayoutInflater.inflate(R.layout.user_selecte_item, null);
		UserInfo userInfo = mList.get(position);
		Drawable drawable = userInfo.getUserIcon();
		LogUtil.i(this, drawable.getMinimumWidth()+"");
		drawable.setBounds(0, 0, 50, 50);
		holder.rName.setCompoundDrawables(drawable, null, null, null);
		holder.rName.setText(userInfo.getUserName());
/*
		if (convertView != null)

		{
			TextView _TextView1 = (TextView) convertView.findViewById(R.id.user_name);
			_TextView1.setCompoundDrawables(userInfo.getUserIcon(), null, null, null);
			TextView _TextView2 = (TextView) convertView.findViewById(R.id.textView2);
			_TextView1.setText(mList.get(position).getUserName());
			_TextView2.setText("");

		}*/

		return row;
	}

}
